<!DOCTYPE html>
<html>

	<%- include('../includes/head') %>
	
	<body class="hold-transition skin-blue sidebar-mini">

		<div class="wrapper">

			<!-- The header is the topbar -->
			<%- include('../includes/header') %>

			<!-- The sidebar includes the menu -->
			<%- include('../includes/sidebar') %>

			<!-- Content Wrapper. Contains page content -->
			<div class="content-wrapper">

				<!-- Content Header (Page header) -->
				<section class="content-header">
					<h1> <%= translate("common:CONFIGURATION") %> <small> Version 1.0.0-beta </small> </h1>
					<ol class="breadcrumb">
                        <li><a href="/"><i class="fa fa-home"></i> <%= translate("dashboard:SELECTOR") %></a></li>
                        <li class="active"><%= guild.name %></li>
					</ol>
				</section>

				<section class="content">
                    <div class="row">
                        <div class="col-md-6">
                            <div class="box box-widget widget-user">
                                <div class="widget-user-header bg-aqua-active">
                                    <h3 class="widget-user-username"><%= guild.name %></h3>
                                </div>
                                <div class="widget-user-image">
                                    <img class="img-circle" src="<%= guild.iconURL %>" alt="Server icon">
                                </div>
                                <div class="box-footer">
                                    <div class="row">
                                        <div class="col-sm-12 border-right">
                                            <div class="description-block">
                                                <h5 class="description-header"><%= guild.memberCount %></h5>
                                                <span class="description-text"><%= translate("common:MEMBERS") %></span>
                                            </div>
                                            <!-- /.description-block -->
                                        </div>
                                        <!-- /.col -->
                                    </div>
                                    <!-- /.row -->
                                </div>
                                <!-- /.box-footer -->
                            </div>
                            <!-- BASIC CONFIGURATION -->
                            <div class="box box-warning">
                                <div class="box-header with-border">
                                    <h3 class="box-title"><%= translate("dashboard:BASIC_CONF") %></h3>
                                </div>
                                <form role="form" action="/manage/<%= guild.id %>/" method="POST">
                                    <!-- /.box-header -->
                                    <div class="box-body">
                                        <!-- text input -->
                                        <div class="form-group">
                                            <label><%= translate("common:PREFIX") %></label>
                                            <input type="text" name="prefix" class="form-control" placeholder="<%= guild.prefix %>">
                                        </div>
                                        <!-- select -->
                                        <div class="form-group">
                                            <label><%= translate("common:LANGUAGE") %></label>
                                            <select class="form-control" name="language">
                                                <% bot.languages.forEach((language) => { %>
                                                    <% if(guild.language === language.name){ %>
                                                        <option selected="selected"><%= language.aliases[0] %></option>
                                                    <% } else { %>
                                                        <option><%= language.aliases[0] %></options>
                                                    <% } %>
                                                <% }) %>
                                            </select>
                                        </div>
                                    </div>
                                    <!-- /.box-body -->
                                    <div class="box-footer">
                                        <button type="submit" class="btn btn-primary"><%= translate("common:UPDATE") %></button>
                                    </div>
                                </form>
                            </div>
                            <!-- /.box -->
                            <!-- SPECIAL CHANNELS -->
                            <div class="box box-warning">
                                <div class="box-header with-border">
                                    <h3 class="box-title"><%= translate("dashboard:CHANNELS_CONF") %></h3>
                                </div>
                                <form role="form" action="/manage/<%= guild.id %>/" method="POST">
                                    <!-- /.box-header -->
                                    <div class="box-body">
                                        <!-- select -->
                                        <div class="form-group">
                                            <label><%= translate("common:SUGGESTIONS") %></label>
                                            <select class="form-control" name="suggestions">
                                                <% if(guild.plugins.suggestions && bot.channels.cache.has(guild.plugins.suggestions)){ %>
                                                    <option selected="selected">#<%= bot.channels.cache.get(guild.plugins.suggestions).name %></option>
                                                    <% guild.channels.cache.filter((ch) => ch.type === "text" && ch.id !== guild.plugins.suggestions).forEach((ch) => { %>
                                                        <option>#<%= ch.name %></option>
                                                    <% }); %>
                                                        <option><%= translate("common:NO_CHANNEL") %></option>
                                                <% } else { %>
                                                    <option selected="selected"><%= translate("common:NO_CHANNEL") %></option>
                                                    <% guild.channels.cache.filter((ch) => ch.type === "text").forEach((ch) => { %>
                                                        <option>#<%= ch.name %></option>
                                                    <% }); %>
                                                <% } %>
                                            </select>
                                        </div>
                                        <div class="form-group">
                                            <label><%= translate("common:MODLOGS") %></label>
                                            <select class="form-control" name="modlogs">
                                                <% if(guild.plugins.modlogs && bot.channels.cache.has(guild.plugins.modlogs)){ %>
                                                    <option selected="selected">#<%= bot.channels.cache.get(guild.plugins.modlogs).name %></option>
                                                    <% guild.channels.cache.filter((ch) => ch.type === "text" && ch.id !== guild.plugins.modlogs).forEach((ch) => { %>
                                                        <option>#<%= ch.name %></option>
                                                    <% }); %>
                                                        <option><%= translate("common:NO_CHANNEL") %></option>
                                                <% } else { %>
                                                    <option selected="selected"><%= translate("common:NO_CHANNEL")%></option>
                                                    <% guild.channels.cache.filter((ch) => ch.type === "text").forEach((ch) => { %>
                                                        <option>#<%= ch.name %></option>
                                                    <% }); %>
                                                <% } %>
                                            </select>
                                        </div>
                                        <div class="form-group">
                                            <label><%= translate("common:FORTNITESHOP") %></label>
                                            <select class="form-control" name="fortniteshop">
                                                <% if(guild.plugins.fortniteshop && bot.channels.cache.has(guild.plugins.fortniteshop)){ %>
                                                    <option selected="selected">#<%= bot.channels.cache.get(guild.plugins.fortniteshop).name %></option>
                                                    <% guild.channels.cache.filter((ch) => ch.type === "text" && ch.id !== guild.plugins.fortniteshop).forEach((ch) => { %>
                                                        <option>#<%= ch.name %></option>
                                                    <% }); %>
                                                        <option><%= translate("common:NO_CHANNEL") %></option>
                                                <% } else { %>
                                                    <option selected="selected"><%= translate("common:NO_CHANNEL")%></option>
                                                    <% guild.channels.cache.filter((ch) => ch.type === "text").forEach((ch) => { %>
                                                        <option>#<%= ch.name %></option>
                                                    <% }); %>
                                                <% } %>
                                            </select>
                                        </div>
                                    </div>
                                    <!-- /.box-body -->
                                    <div class="box-footer">
                                        <button type="submit" class="btn btn-primary"><%= translate("common:UPDATE") %></button>
                                    </div>
                                </form>
                            </div>
                            <!-- /.box -->
                        </div>
                        <div class="col-md-6">
                            <!-- WELCOME CONFIGURATION -->
                            <div class="box box-success">
                                <div class="box-header with-border">
                                    <h3 class="box-title"><%= translate("dashboard:WELCOME_CONF") %></h3>
                                </div>
                                <form role="form" action="/manage/<%= guild.id %>/" method="POST">
                                    <!-- /.box-header -->
                                    <div class="box-body">
                                        <!-- text input -->
                                        <div class="form-group">
                                            <label><%= translate("common:MESSAGE") %></label>
                                            <textarea rows="3" name="message" class="form-control" required><%= (guild.plugins.welcome.message || translate("administration/welcome:DEFAULT_MESSAGE")) %></textarea>
                                        </div>
                                        <!-- select -->
                                        <div class="form-group">
                                            <label><%= translate("common:CHANNEL") %></label>
                                            <select class="form-control" name="channel">
                                                <% if(guild.plugins.welcome.enabled && bot.channels.cache.has(guild.plugins.welcome.channel)){ %>
                                                    <option selected="selected">#<%= bot.channels.cache.get(guild.plugins.welcome.channel).name %></option>
                                                    <% guild.channels.cache.filter((ch) => ch.id !== guild.plugins.welcome.channel && ch.type === "text").forEach((ch) => { %>
                                                        <option>#<%= ch.name %></option>
                                                    <% }); } else { %>
                                                    <option selected="selected">#<%= guild.channels.cache.filter((ch) => ch.type === "text").first().name %></option>
                                                    <% guild.channels.cache.filter((ch) => ch.id !== guild.channels.cache.first().id && ch.type === "text").forEach((ch) => { %>
                                                        <option>#<%= ch.name %></option>
                                                    <% }); %>
                                                <% } %>
                                            </select>
                                        </div>
                                        <!-- select -->
                                        <div class="form-group">
                                            <div class="checkbox">
                                                <label>
                                                    <% if(guild.plugins.welcome.withImage || !guild.plugins.welcome.enabled) { %>
                                                        <input type="checkbox" name="withImage" checked><%= translate("dashboard:WELCOME_IMG") %>
                                                    <% } else { %>
                                                        <input type="checkbox" name="withImage"><%= translate("dashboard:WELCOME_IMG") %>
                                                    <% } %>
                                                </label>
                                            </div>
                                        </div>
                                    </div>
                                    <!-- /.box-body -->
                                    <div class="box-footer">
                                        <% if(guild.plugins.welcome.enabled){ %>
                                            <button type="submit" name="welcomeDisable" class="btn btn-danger"><%= translate("dashboard:DISABLE_MESSAGES") %></button>
                                            <button type="submit" name="welcomeUpdate" class="btn btn-primary pull-right"><%= translate("common:UPDATE") %></button>
                                        <% } else { %>
                                            <button type="submit" name="welcomeEnable" class="btn btn-success"><%= translate("dashboard:ENABLE_MESSAGES") %></button>
                                        <% } %>
                                    </div>
                                </form>
                            </div>
                            <!-- GOODBYE CONFIGURATION -->
                            <div class="box box-danger">
                                <div class="box-header with-border">
                                    <h3 class="box-title"><%= translate("dashboard:GOODBYE_CONF") %></h3>
                                </div>
                                <form role="form" action="/manage/<%= guild.id %>/" method="POST">
                                    <!-- /.box-header -->
                                    <div class="box-body">
                                        <!-- text input -->
                                        <div class="form-group">
                                            <label><%= translate("common:MESSAGE") %></label>
                                            <textarea rows="3" name="message" class="form-control" required><%= (guild.plugins.goodbye.message || translate("administration/goodbye:DEFAULT_MESSAGE")) %></textarea>
                                        </div>
                                        <!-- select -->
                                        <div class="form-group">
                                            <label><%= translate("common:CHANNEL") %></label>
                                            <select class="form-control" name="channel">
                                                <% if(guild.plugins.goodbye.enabled && bot.channels.cache.has(guild.plugins.goodbye.channel)){ %>
                                                    <option selected="selected">#<%= bot.channels.cache.get(guild.plugins.goodbye.channel).name %></option>
                                                    <% guild.channels.cache.filter((ch) => ch.id !== guild.plugins.goodbye.channel && ch.type === "text").forEach((ch) => { %>
                                                        <option>#<%= ch.name %></option>
                                                    <% }); } else { %>
                                                    <option selected="selected">#<%= guild.channels.cache.filter((ch) => ch.type === "text").first().name %></option>
                                                    <% guild.channels.cache.filter((ch) => ch.id !== guild.channels.cache.first().id && ch.type === "text").forEach((ch) => { %>
                                                        <option>#<%= ch.name %></option>
                                                    <% }); %>
                                                <% } %>
                                            </select>
                                        </div>
                                        <!-- select -->
                                        <div class="form-group">
                                            <div class="checkbox">
                                                <label>
                                                    <% if(guild.plugins.goodbye.withImage || !guild.plugins.goodbye.enabled) { %>
                                                        <input type="checkbox" name="withImage" checked><%= translate("dashboard:GOODBYE_IMG") %>
                                                    <% } else { %>
                                                        <input type="checkbox" name="withImage"><%= translate("dashboard:GOODBYE_IMG") %>
                                                    <% } %>
                                                </label>
                                            </div>
                                        </div>
                                    </div>
                                    <!-- /.box-body -->
                                    <div class="box-footer">
                                        <% if(guild.plugins.goodbye.enabled){ %>
                                            <button type="submit" name="goodbyeDisable" class="btn btn-danger"><%= translate("dashboard:DISABLE_MESSAGES") %></button>
                                            <button type="submit" name="goodbyeUpdate" class="btn btn-primary pull-right"><%= translate("common:UPDATE") %></button>
                                        <% } else { %>
                                            <button type="submit" name="goodbyeEnable" class="btn btn-success"><%= translate("dashboard:ENABLE_MESSAGES") %></button>
                                        <% } %>
                                    </div>
                                </form>
                            </div>
                            <!-- AUTOROLE CONFIGURATION -->
                            <div class="box box-warning">
                                <div class="box-header with-border">
                                    <h3 class="box-title"><%= translate("dashboard:AUTOROLE_CONF") %></h3>
                                </div>
                                <form role="form" action="/manage/<%= guild.id %>/" method="POST">
                                    <!-- /.box-header -->
                                    <div class="box-body">
                                        <!-- select -->
                                        <div class="form-group">
                                            <label><%= translate("common:ROLE") %></label>
                                            <select class="form-control" name="role">
                                                <% if(guild.plugins.autorole.enabled && guild.roles.cache.has(guild.plugins.autorole.role)){ %>
                                                    <option selected="selected">@<%= guild.roles.cache.get(guild.plugins.autorole.role).name %></option>
                                                    <% guild.roles.cache.filter((r) => r.id !== guild.plugins.autorole.role && r.name !== "@everyone").forEach((r) => { %>
                                                        <option>@<%= r.name %></option>
                                                    <% }); } else { %>
                                                    <option selected="selected">@<%= guild.roles.cache.filter((r) => r.name !== "@everyone").first().name %></option>
                                                    <% guild.roles.cache.filter((r) => r.id !== guild.roles.cache.filter((r) => r.name !== "@everyone").first().id && r.name !== "@everyone").forEach((r) => { %>
                                                        <option>@<%= r.name %></option>
                                                    <% }); %>
                                                <% } %>
                                            </select>
                                        </div>
                                    </div>
                                    <!-- /.box-body -->
                                    <div class="box-footer">
                                        <% if(guild.plugins.autorole.enabled){ %>
                                            <button type="submit" name="autoroleDisable" class="btn btn-danger"><%= translate("dashboard:DISABLE_AUTOROLE") %></button>
                                            <button type="submit" name="autoroleUpdate" class="btn btn-primary pull-right"><%= translate("common:UPDATE") %></button>
                                        <% } else { %>
                                            <button type="submit" name="autoroleEnable" class="btn btn-success"><%= translate("dashboard:ENABLE_AUTOROLE") %></button>
                                        <% } %>
                                    </div>
                                </form>
                            </div>
                            <!-- /.box -->
                        </div>
                    <div>
				</section>
				
				<!-- Footer includes credits and version -->
			</div>
            <!-- /.content-wrapper -->
            
            <%- include('../includes/footer') %>
		</div>
		<!-- ./wrapper -->
	</body>
</html>